home *** CD-ROM | disk | FTP | other *** search
/ Programming a Multiplayer FPS in DirectX / Programming a Multiplayer FPS in DirectX (Companion CD).iso / DirectX / dxsdk_oct2004.exe / dxsdk.exe / Samples / C++ / Direct3D / HLSLWithoutEffects / HLSLwithoutEffects.vsh < prev    next >
Encoding:
Text File  |  2004-09-27  |  2.0 KB  |  55 lines

  1. //-----------------------------------------------------------------------------
  2. // File: HLSLwithoutEffects.vsh
  3. //
  4. // Desc: The effect file for the BasicHLSL sample.  It contains a vertex 
  5. //         shader which animates the vertices.
  6. // 
  7. // Copyright (c) Microsoft Corporation. All rights reserved.
  8. //-----------------------------------------------------------------------------
  9.  
  10.  
  11. //-----------------------------------------------------------------------------
  12. // Global variables
  13. //-----------------------------------------------------------------------------
  14. float4x4 mWorldViewProj;  // World * View * Projection transformation
  15. float fTime;              // Time parameter. This keeps increasing
  16.  
  17.  
  18. //-----------------------------------------------------------------------------
  19. // Vertex shader output structure
  20. //-----------------------------------------------------------------------------
  21. struct VS_OUTPUT
  22. {
  23.     float4 Position   : POSITION;   // vertex position 
  24.     float4 Diffuse    : COLOR0;     // vertex diffuse color
  25. };
  26.  
  27.  
  28. //-----------------------------------------------------------------------------
  29. // Name: Ripple
  30. // Type: Vertex shader                                      
  31. // Desc: This shader ripples the vertices
  32. //-----------------------------------------------------------------------------
  33. VS_OUTPUT Ripple( in float2 vPosition : POSITION )
  34. {
  35.     VS_OUTPUT Output;
  36.     
  37.     float fSin, fCos;   
  38.     float x = length( vPosition ) * sin( fTime ) * 15.0f;
  39.     
  40.     // This HLSL intrinsic computes returns both the sine and cosine of x
  41.     sincos( x, fSin, fCos );
  42.  
  43.     // Change the y of the vertex position based on a function of time 
  44.     // and transform the vertex into projection space. 
  45.     Output.Position = mul( float4( vPosition.x, fSin * 0.1f, vPosition.y, 1.0f ), mWorldViewProj );
  46.     
  47.     // Output the diffuse color as function of time and 
  48.     // the vertex's object space position
  49.     Output.Diffuse = 0.5f - 0.5f * fCos;
  50.     
  51.     return Output;
  52. }
  53.  
  54.  
  55.